<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Schengen extends CI_Controller {

	function __construct()
	{
		parent::__construct();
	}
	
	/**
	 * 申根入口
	 */
	public function index()
	{

	}
	
	/**
	 * 22.法国申根
	 */
	public function fr($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Fr_Model','',TRUE);
			$info = $this->Schengen_Fr_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_fr', $data);
	}
	
	/**
	 * 22.法国申根更新
	 */
	public function fr_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Fr_Model','',TRUE);
		$info = $this->Schengen_Fr_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Fr_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Fr_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Fr_Model->update_entry($id, $attach);
		
		redirect('schengen/fr/'.$id.'/'.$cateid);
	}
	
	/**
	 * 23.法国申根附表
	 */
	public function fr_ext($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Fr_Ext_Model','',TRUE);
			$info = $this->Schengen_Fr_Ext_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_m.'/'.$idcard->birth_d.'/'.$idcard->birth_y;
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_fr_ext', $data);
	}
	
	/**
	 * 23.法国申根附表更新
	 */
	public function fr_ext_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Fr_Ext_Model','',TRUE);
		$info = $this->Schengen_Fr_Ext_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Fr_Ext_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Fr_Ext_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		redirect('schengen/fr_ext/'.$id.'/'.$cateid);
	}

	/**
	 * 24.意大利申根
	 */
	public function it($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_It_Model','',TRUE);
			$info = $this->Schengen_It_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_it', $data);
	}
	
	/**
	 * 24.意大利申根更新
	 */
	public function it_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_It_Model','',TRUE);
		$info = $this->Schengen_It_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_It_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_It_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_It_Model->update_entry($id, $attach);
		
		redirect('schengen/it/'.$id.'/'.$cateid);
	}
	
	
	/**
	 * 25.西班牙申根
	 */
	public function es($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Es_Model','',TRUE);
			$info = $this->Schengen_Es_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_es', $data);
	}
	
	/**
	 * 25.西班牙申根更新
	 */
	public function es_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Es_Model','',TRUE);
		$info = $this->Schengen_Es_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Es_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Es_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Es_Model->update_entry($id, $attach);
		
		redirect('schengen/es/'.$id.'/'.$cateid);
	}	
	
	
	/**
	 * 26.加拿大申根
	 */
	public function ca($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ca_Model','',TRUE);
			$info = $this->Schengen_Ca_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
            $info->family_name = $idcard->surname; 
            $info->given_name = $idcard->firstname; 
			$info->former = $idcard->surname;
			if (!empty($info->passport_issue)){
				$arr = explode("/", $info->passport_issue);
				$info->passport_issue = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			if (!empty($info->passport_expiry)){
				$arr = explode("/", $info->passport_expiry);
				$info->passport_expiry = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ca', $data);
	}
	
	/**
	 * 26.加拿大申根更新
	 */
	public function ca_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ca_Model','',TRUE);
		$info = $this->Schengen_Ca_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ca_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ca_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ca_Model->update_entry($id, $attach);
		
		redirect('schengen/ca/'.$id.'/'.$cateid);
	}		
	
	/**
	 * 27.加拿大家庭信息
	 */
	public function ca_family($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ca_Family_Model','',TRUE);
			$info = $this->Schengen_Ca_Family_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->former = $idcard->surname;
            $info->applicant_name = $idcard->surname . $idcard->firstname;        
            $info->applicant_birth_y = $idcard->birth_y;        
            $info->applicant_birth_m = $idcard->birth_m;        
            $info->applicant_birth_d = $idcard->birth_d;        
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ca_family', $data);
	}
	
	/**
	 * 27.加拿大家庭信息更新
	 */
	public function ca_family_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ca_Family_Model','',TRUE);
		$info = $this->Schengen_Ca_Family_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ca_Family_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ca_Family_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		redirect('schengen/ca_family/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 28.加拿大教育和就业细节表
	 */
	public function ca_ee($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ca_EE_Model','',TRUE);
			$info = $this->Schengen_Ca_EE_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ca_ee', $data);
	}
	
	/**
	 * 28.加拿大教育和就业细节表更新
	 */
	public function ca_ee_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ca_EE_Model','',TRUE);
		$info = $this->Schengen_Ca_EE_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ca_EE_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ca_EE_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		redirect('schengen/ca_ee/'.$id.'/'.$cateid);
	}		

	/**
	 * 29.澳大利亚旅游申根
	 */
	public function au_tourism($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Au_Tourism_Model','',TRUE);
			$info = $this->Schengen_Au_Tourism_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'-'.$idcard->birth_m.'-'.$idcard->birth_y;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_au_tourism', $data);
	}
	
	/**
	 * 29.澳大利亚旅游申根更新
	 */
	public function au_tourism_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Au_Tourism_Model','',TRUE);
		$info = $this->Schengen_Au_Tourism_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Au_Tourism_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Au_Tourism_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Au_Tourism_Model->update_entry($id, $attach);
		
		redirect('schengen/au_tourism/'.$id.'/'.$cateid);
	}
	
	/**
	 * 30.澳大利亚商务申根
	 */
	public function au_business($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Au_Business_Model','',TRUE);
			$info = $this->Schengen_Au_Business_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'-'.$idcard->birth_m.'-'.$idcard->birth_y;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_au_business', $data);
	}
	
	/**
	 * 30.澳大利亚商务申根更新
	 */
	public function au_business_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Au_Business_Model','',TRUE);
		$info = $this->Schengen_Au_Business_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Au_Business_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Au_Business_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Au_Business_Model->update_entry($id, $attach);
		
		redirect('schengen/au_business/'.$id.'/'.$cateid);
	}
	
	/**
	 * 31.澳大利亚家庭构成
	 */
	public function au_family($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Au_Family_Model','',TRUE);
			$info = $this->Schengen_Au_Family_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->cn_r1_c1 = $idcard->surname;
			$info->en_r1_c1 = $idcard->surname;
			$info->cn_r1_c2 = $idcard->firstname;
			$info->en_r1_c2 = $idcard->firstname;
			$info->cn_r1_c3 = $idcard->birth_d.'-'.$idcard->birth_m.'-'.$idcard->birth_y;
			$info->en_r1_c3 = $idcard->birth_d.'-'.$idcard->birth_m.'-'.$idcard->birth_y;
			$info->cn_r1_c5 = $idcard->home_address;
			$info->en_r1_c5 = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_au_family', $data);
	}
	
	/**
	 * 31.澳大利亚家庭构成更新
	 */
	public function au_family_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Au_Family_Model','',TRUE);
		$info = $this->Schengen_Au_Family_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Au_Family_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Au_Family_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		redirect('schengen/au_family/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 32.新西兰旅游申根
	 */
	public function nz_tourism($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Nz_Tourism_Model','',TRUE);
			$info = $this->Schengen_Nz_Tourism_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_nz_tourism', $data);
	}
	
	/**
	 * 32.新西兰旅游申根更新
	 */
	public function nz_tourism_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Nz_Tourism_Model','',TRUE);
		$info = $this->Schengen_Nz_Tourism_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Nz_Tourism_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Nz_Tourism_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Nz_Tourism_Model->update_entry($id, $attach);
		
		redirect('schengen/nz_tourism/'.$id.'/'.$cateid);
	}
	
	/**
	 * 33.新西兰商务申根
	 */
	public function nz_business($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Nz_Business_Model','',TRUE);
			$info = $this->Schengen_Nz_Business_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_nz_business', $data);
	}
	
	/**
	 * 33.新西兰商务申根更新
	 */
	public function nz_business_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Nz_Business_Model','',TRUE);
		$info = $this->Schengen_Nz_Business_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Nz_Business_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Nz_Business_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Nz_Business_Model->update_entry($id, $attach);
		
		redirect('schengen/nz_business/'.$id.'/'.$cateid);
	}
	
	/**
	 * 34.新西兰附表
	 */
	public function nz_ext($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Nz_Ext_Model','',TRUE);
			$info = $this->Schengen_Nz_Ext_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $idcard->surname.' '.$idcard->firstname;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_nz_ext', $data);
	}
	
	/**
	 * 34.新西兰附表更新
	 */
	public function nz_ext_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Nz_Ext_Model','',TRUE);
		$info = $this->Schengen_Nz_Ext_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Nz_Ext_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Nz_Ext_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		redirect('schengen/nz_ext/'.$id.'/'.$cateid);
	}
	
	/**
	 * 35.英国旅游访问签证
	 */
	public function uk_tourism($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Uk_Tourism_Model','',TRUE);
			$info = $this->Schengen_Uk_Tourism_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_uk_tourism', $data);
	}
	
	/**
	 * 35.英国旅游访问签证更新
	 */
	public function uk_tourism_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Uk_Tourism_Model','',TRUE);
		$info = $this->Schengen_Uk_Tourism_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Uk_Tourism_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Uk_Tourism_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Uk_Tourism_Model->update_entry($id, $attach);
		
		redirect('schengen/uk_tourism/'.$id.'/'.$cateid);
	}
	
	/**
	 * 36.英国家庭访问签证
	 */
	public function uk_family($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Uk_Family_Model','',TRUE);
			$info = $this->Schengen_Uk_Family_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_uk_family', $data);
	}
	
	/**
	 * 36.英国家庭访问签证更新
	 */
	public function uk_family_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Uk_Family_Model','',TRUE);
		$info = $this->Schengen_Uk_Family_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Uk_Family_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Uk_Family_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Uk_Family_Model->update_entry($id, $attach);
		
		redirect('schengen/uk_family/'.$id.'/'.$cateid);
	}
	
	/**
	 * 37.英国商务访问签证
	 */
	public function uk_business($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Uk_Business_Model','',TRUE);
			$info = $this->Schengen_Uk_Business_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_uk_business', $data);
	}
	
	/**
	 * 37.英国商务访问签证更新
	 */
	public function uk_business_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Uk_Business_Model','',TRUE);
		$info = $this->Schengen_Uk_Business_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Uk_Business_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Uk_Business_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Uk_Business_Model->update_entry($id, $attach);
		
		redirect('schengen/uk_business/'.$id.'/'.$cateid);
	}
	
	/**
	 * 38.奥地利/挪威/瑞士申根
	 */
	public function no($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_No_Model','',TRUE);
			$info = $this->Schengen_No_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_no', $data);
	}
	
	/**
	 * 38.奥地利/挪威/瑞士申根更新
	 */
	public function no_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_No_Model','',TRUE);
		$info = $this->Schengen_No_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_No_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_No_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_No_Model->update_entry($id, $attach);
		
		redirect('schengen/no/'.$id.'/'.$cateid);
	}
	
	/**
	 * 39.阿根廷商务旅游申请
	 */
	public function ar($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ar_Model','',TRUE);
			$info = $this->Schengen_Ar_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ar', $data);
	}
	
	/**
	 * 39.阿根廷商务旅游申请更新
	 */
	public function ar_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ar_Model','',TRUE);
		$info = $this->Schengen_Ar_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ar_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ar_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ar_Model->update_entry($id, $attach);
		
		redirect('schengen/ar/'.$id.'/'.$cateid);
	}

	/**
	 * 40.哥伦比亚商务旅游申请
	 */
	public function co($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Co_Model','',TRUE);
			$info = $this->Schengen_Co_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_co', $data);
	}
	
	/**
	 * 40.哥伦比亚商务旅游申请更新
	 */
	public function co_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Co_Model','',TRUE);
		$info = $this->Schengen_Co_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Co_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Co_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Co_Model->update_entry($id, $attach);
		
		redirect('schengen/co/'.$id.'/'.$cateid);
	}

	/**
	 * 41.玻利维亚申请
	 */
	public function bo($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Bo_Model','',TRUE);
			$info = $this->Schengen_Bo_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_bo', $data);
	}
	
	/**
	 * 41. 玻利维亚申请更新
	 */
	public function bo_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Bo_Model','',TRUE);
		$info = $this->Schengen_Bo_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Bo_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Bo_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Bo_Model->update_entry($id, $attach);
		
		redirect('schengen/bo/'.$id.'/'.$cateid);
	}
	
	/**
	 * 42.厄瓜多尔申请
	 */
	public function ec($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ec_Model','',TRUE);
			$info = $this->Schengen_Ec_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->name = $info->surname.' '.$info->firstname;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ec', $data);
	}
	
	/**
	 * 42. 厄瓜多尔申请更新
	 */
	public function ec_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ec_Model','',TRUE);
		$info = $this->Schengen_Ec_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ec_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ec_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ec_Model->update_entry($id, $attach);
		
		redirect('schengen/ec/'.$id.'/'.$cateid);
	}
	
	/**
	 * 43.委内瑞拉申请
	 */
	public function ve($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ve_Model','',TRUE);
			$info = $this->Schengen_Ve_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ve', $data);
	}
	
	/**
	 * 43. 委内瑞拉申请更新
	 */
	public function ve_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ve_Model','',TRUE);
		$info = $this->Schengen_Ve_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ve_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ve_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ve_Model->update_entry($id, $attach);
		
		redirect('schengen/ve/'.$id.'/'.$cateid);
	}
	
	/**
	 * 44.智利申请
	 */
	public function cl($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Cl_Model','',TRUE);
			$info = $this->Schengen_Cl_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_cl', $data);
	}
	
	/**
	 * 44. 智利申请更新
	 */
	public function cl_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Cl_Model','',TRUE);
		$info = $this->Schengen_Cl_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Cl_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Cl_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Cl_Model->update_entry($id, $attach);
		
		redirect('schengen/cl/'.$id.'/'.$cateid);
	}
	
	/**
	 * 45.墨西哥申请
	 */
	public function mx($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Mx_Model','',TRUE);
			$info = $this->Schengen_Mx_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_mx', $data);
	}
	
	/**
	 * 45. 墨西哥申请更新
	 */
	public function mx_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Mx_Model','',TRUE);
		$info = $this->Schengen_Mx_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Mx_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Mx_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Mx_Model->update_entry($id, $attach);
		
		redirect('schengen/mx/'.$id.'/'.$cateid);
	}
	
	/**
	 * 46.牙买加申请
	 */
	public function jm($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Jm_Model','',TRUE);
			$info = $this->Schengen_Jm_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_jm', $data);
	}
	
	/**
	 * 46.牙买加申请更新
	 */
	public function jm_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Jm_Model','',TRUE);
		$info = $this->Schengen_Jm_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Jm_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Jm_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Jm_Model->update_entry($id, $attach);
		
		redirect('schengen/jm/'.$id.'/'.$cateid);
	}
	
	/**
	 * 47.埃及旅游签证
	 */
	public function eg_tourism($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Eg_Tourism_Model','',TRUE);
			$info = $this->Schengen_Eg_Tourism_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'-'.$idcard->birth_m.'-'.$idcard->birth_y;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_eg_tourism', $data);
	}
	
	/**
	 * 47.埃及旅游签证更新
	 */
	public function eg_tourism_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Eg_Tourism_Model','',TRUE);
		$info = $this->Schengen_Eg_Tourism_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Eg_Tourism_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Eg_Tourism_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Eg_Tourism_Model->update_entry($id, $attach);
		
		redirect('schengen/eg_tourism/'.$id.'/'.$cateid);
	}
	
	/**
	 * 48.埃及商务签证
	 */
	public function eg_business($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Eg_Business_Model','',TRUE);
			$info = $this->Schengen_Eg_Business_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'-'.$idcard->birth_m.'-'.$idcard->birth_y;
			$info->former = $idcard->surname;
			$info->applicant_address = $idcard->home_address;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_eg_business', $data);
	}
	
	/**
	 * 48.埃及商务签证更新
	 */
	public function eg_business_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Eg_Business_Model','',TRUE);
		$info = $this->Schengen_Eg_Business_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Eg_Business_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Eg_Business_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		//$attach = $this->_uploadProcess($id);
		//if (! empty($attach) ) $this->Schengen_Eg_Tourism_Model->update_entry($id, $attach);
		
		redirect('schengen/eg_business/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 49.津巴布韦签证
	 */
	public function zw($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Zw_Model','',TRUE);
			$info = $this->Schengen_Zw_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
			$info->sex = $info->sex==1 ? 'Male' : 'Female';
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_zw', $data);
	}
	
	/**
	 * 49.津巴布韦签证更新
	 */
	public function zw_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Zw_Model','',TRUE);
		$info = $this->Schengen_Zw_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Zw_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Zw_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Zw_Model->update_entry($id, $attach);
		
		redirect('schengen/zw/'.$id.'/'.$cateid);
	}
	
	/**
	 * 50.摩洛哥签证
	 */
	public function ma($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ma_Model','',TRUE);
			$info = $this->Schengen_Ma_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ma', $data);
	}
	
	/**
	 * 50.摩洛哥签证更新
	 */
	public function ma_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ma_Model','',TRUE);
		$info = $this->Schengen_Ma_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ma_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ma_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ma_Model->update_entry($id, $attach);
		
		redirect('schengen/ma/'.$id.'/'.$cateid);
	}
	
	/**
	 * 51.南非签证
	 */
	public function za($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Za_Model','',TRUE);
			$info = $this->Schengen_Za_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_za', $data);
	}
	
	/**
	 * 51.南非签证更新
	 */
	public function za_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Za_Model','',TRUE);
		$info = $this->Schengen_Za_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Za_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Za_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Za_Model->update_entry($id, $attach);
		
		redirect('schengen/za/'.$id.'/'.$cateid);
	}
	
	/**
	 * 52.纳米比亚签证
	 */
	public function na($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Na_Model','',TRUE);
			$info = $this->Schengen_Na_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->is_valid_for = 1;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_na', $data);
	}
	
	/**
	 * 52.纳米比亚签证更新
	 */
	public function na_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Na_Model','',TRUE);
		$info = $this->Schengen_Na_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Na_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Na_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Na_Model->update_entry($id, $attach);
		
		redirect('schengen/na/'.$id.'/'.$cateid);
	}
	
	/**
	 * 53.坦桑尼亚签证
	 */
	public function tz($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Tz_Model','',TRUE);
			$info = $this->Schengen_Tz_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_tz', $data);
	}
	
	/**
	 * 53.坦桑尼亚签证更新
	 */
	public function tz_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Tz_Model','',TRUE);
		$info = $this->Schengen_Tz_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Tz_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Tz_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Tz_Model->update_entry($id, $attach);
		
		redirect('schengen/tz/'.$id.'/'.$cateid);
	}
	
	/**
	 * 54.韩国签证
	 */
	public function kr($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Kr_Model','',TRUE);
			$info = $this->Schengen_Kr_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_kr', $data);
	}
	
	/**
	 * 54.韩国签证更新
	 */
	public function kr_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Kr_Model','',TRUE);
		$info = $this->Schengen_Kr_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Kr_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Kr_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Kr_Model->update_entry($id, $attach);
		
		redirect('schengen/kr/'.$id.'/'.$cateid);
	}
	
	/**
	 * 55.日本签证
	 */
	public function jp($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Jp_Model','',TRUE);
			$info = $this->Schengen_Jp_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_jp', $data);
	}
	
	/**
	 * 55.日本签证更新
	 */
	public function jp_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Jp_Model','',TRUE);
		$info = $this->Schengen_Jp_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Jp_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Jp_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Jp_Model->update_entry($id, $attach);
		
		redirect('schengen/jp/'.$id.'/'.$cateid);
	}
	
	/**
	 * 56.新加坡签证
	 */
	public function sg($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Sg_Model','',TRUE);
			$info = $this->Schengen_Sg_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $info->surname.' '.$info->firstname;
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_sg', $data);
	}
	
	/**
	 * 56.新加坡签证更新
	 */
	public function sg_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Sg_Model','',TRUE);
		$info = $this->Schengen_Sg_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Sg_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Sg_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Sg_Model->update_entry($id, $attach);
		
		redirect('schengen/sg/'.$id.'/'.$cateid);
	}
	
	
	/**
	 * 57.马来西亚签证
	 */
	public function my($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_My_Model','',TRUE);
			$info = $this->Schengen_My_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $info->surname.' '.$info->firstname;
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_my', $data);
	}
	
	/**
	 * 57.马来西亚签证更新
	 */
	public function my_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_My_Model','',TRUE);
		$info = $this->Schengen_My_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_My_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_My_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_My_Model->update_entry($id, $attach);
		
		redirect('schengen/my/'.$id.'/'.$cateid);
	}
	
	/**
	 * 58.越南签证
	 */
	public function vn($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Vn_Model','',TRUE);
			$info = $this->Schengen_Vn_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = strtoupper($info->surname.' '.$info->firstname);
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_vn', $data);
	}
	
	/**
	 * 58.越南签证更新
	 */
	public function vn_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Vn_Model','',TRUE);
		$info = $this->Schengen_Vn_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Vn_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Vn_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Vn_Model->update_entry($id, $attach);
		
		redirect('schengen/vn/'.$id.'/'.$cateid);
	}
	
	/**
	 * 59.缅甸签证
	 */
	public function mm($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Mm_Model','',TRUE);
			$info = $this->Schengen_Mm_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $info->surname.' '.$info->firstname;
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_mm', $data);
	}
	
	/**
	 * 59.缅甸签证更新
	 */
	public function mm_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Mm_Model','',TRUE);
		$info = $this->Schengen_Mm_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Mm_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Mm_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Mm_Model->update_entry($id, $attach);
		
		redirect('schengen/mm/'.$id.'/'.$cateid);
	}
	
	/**
	 * 60.菲律宾北京签证
	 */
	public function ph($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ph_Model','',TRUE);
			$info = $this->Schengen_Ph_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $info->surname.' '.$info->firstname;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ph', $data);
	}
	
	/**
	 * 60.菲律宾北京签证更新
	 */
	public function ph_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ph_Model','',TRUE);
		$info = $this->Schengen_Ph_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ph_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ph_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ph_Model->update_entry($id, $attach);
		
		redirect('schengen/ph/'.$id.'/'.$cateid);
	}
	
	/**
	 * 61.菲律宾上海签证
	 */
	public function ph_sh($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ph_Sh_Model','',TRUE);
			$info = $this->Schengen_Ph_Sh_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $info->surname.' '.$info->firstname;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ph_sh', $data);
	}
	
	/**
	 * 61.菲律宾上海签证更新
	 */
	public function ph_sh_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ph_Sh_Model','',TRUE);
		$info = $this->Schengen_Ph_Sh_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ph_Sh_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ph_Sh_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ph_Sh_Model->update_entry($id, $attach);
		
		redirect('schengen/ph_sh/'.$id.'/'.$cateid);
	}


	/**
	 * 62.印尼签证
	 */
	public function id($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Id_Model','',TRUE);
			$info = $this->Schengen_Id_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->surname = strtoupper($info->surname);
			$info->firstname = strtoupper($info->firstname);
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_id', $data);
	}
	
	/**
	 * 62.印尼签证更新
	 */
	public function id_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Id_Model','',TRUE);
		$info = $this->Schengen_Id_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Id_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Id_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Id_Model->update_entry($id, $attach);
		
		redirect('schengen/id/'.$id.'/'.$cateid);
	}


	/**
	 * 63.泰国签证
	 */
	public function th($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Th_Model','',TRUE);
			$info = $this->Schengen_Th_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = strtoupper($info->surname.' '.$info->firstname);
			$info->birth = $idcard->birth_y.'/'.$idcard->birth_m.'/'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_th', $data);
	}
	
	/**
	 * 63.泰国签证更新
	 */
	public function th_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Th_Model','',TRUE);
		$info = $this->Schengen_Th_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Th_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Th_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Th_Model->update_entry($id, $attach);
		
		redirect('schengen/th/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 64.中国主表通用签证
	 */
	public function cn_en($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Cn_En_Model','',TRUE);
			$info = $this->Schengen_Cn_En_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'-'.$idcard->birth_m.'-'.$idcard->birth_d;

			if (!empty($info->travel_document_issue_date)){
				$arr = explode("/", $info->travel_document_issue_date);
				$info->travel_document_issue_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			if (!empty($info->travel_document_valid_date)){
				$arr = explode("/", $info->travel_document_valid_date);
				$info->travel_document_valid_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			$info->avatar = $this->_getAvatar($id);
		}	
		
		//checkbox recover
		$info->occupation = explode(',', @$info->occupation);
		$info->purpose = explode(',', @$info->purpose);
		
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_cn_en', $data);
	}
	
	/**
	 * 64.中国主表通用签证更新
	 */
	public function cn_en_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());	
		$id = $this->input->post('id');

		$this->load->model('Schengen_Cn_En_Model','',TRUE);
		$info = $this->Schengen_Cn_En_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		//checkbox recover
		$msg = $this->input->post();
		$msg['occupation'] = (empty($msg['occupation']))?'':implode(",", $msg['occupation']);
		$msg['purpose'] = (empty($msg['purpose']))?'':implode(",", $msg['purpose']);	
		
		if ( $isExist ){	//insert or update
			$this->Schengen_Cn_En_Model->update_entry($id, $msg);
		}else{
			$this->Schengen_Cn_En_Model->insert_entry($msg);
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Cn_En_Model->update_entry($id, $attach);
		
		redirect('schengen/cn_en/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 65.中国主表纽约签证
	 */
	public function cn_ny($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Cn_Ny_Model','',TRUE);
			$info = $this->Schengen_Cn_Ny_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'-'.$idcard->birth_m.'-'.$idcard->birth_d;

			if (!empty($info->travel_document_issue_date)){
				$arr = explode("/", $info->travel_document_issue_date);
				$info->travel_document_issue_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			if (!empty($info->travel_document_valid_date)){
				$arr = explode("/", $info->travel_document_valid_date);
				$info->travel_document_valid_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			$info->avatar = $this->_getAvatar($id);
		}	
		
		//checkbox recover
		$info->occupation = explode(',', @$info->occupation);
		$info->purpose = explode(',', @$info->purpose);
		
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_cn_ny', $data);
	}
	
	/**
	 * 65.中国主表纽约签证更新
	 */
	public function cn_ny_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());	
		$id = $this->input->post('id');

		$this->load->model('Schengen_Cn_Ny_Model','',TRUE);
		$info = $this->Schengen_Cn_Ny_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		//checkbox recover		
		$msg = $this->input->post();
		$msg['occupation'] = (empty($msg['occupation']))?'':implode(",", $msg['occupation']);
		$msg['purpose'] = (empty($msg['purpose']))?'':implode(",", $msg['purpose']);	

		if ( $isExist ){	//insert or update
			$this->Schengen_Cn_Ny_Model->update_entry($id, $msg);
		}else{
			$this->Schengen_Cn_Ny_Model->insert_entry($msg);
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Cn_Ny_Model->update_entry($id, $attach);
		
		redirect('schengen/cn_ny/'.$id.'/'.$cateid);
	}	
	
	
	/**
	 * 66.中国主表俄文签证
	 */
	public function cn_ru($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Cn_Ru_Model','',TRUE);
			$info = $this->Schengen_Cn_Ru_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'-'.$idcard->birth_m.'-'.$idcard->birth_d;

			if (!empty($info->travel_document_issue_date)){
				$arr = explode("/", $info->travel_document_issue_date);
				$info->travel_document_issue_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			if (!empty($info->travel_document_valid_date)){
				$arr = explode("/", $info->travel_document_valid_date);
				$info->travel_document_valid_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			$info->avatar = $this->_getAvatar($id);
		}	
		
		//checkbox recover
		$info->occupation = explode(',', @$info->occupation);
		$info->purpose = explode(',', @$info->purpose);
		
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_cn_ru', $data);
	}
	
	/**
	 * 66.中国主表俄文签证更新
	 */
	public function cn_ru_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());	
		$id = $this->input->post('id');

		$this->load->model('Schengen_Cn_Ru_Model','',TRUE);
		$info = $this->Schengen_Cn_Ru_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		//checkbox recover		
		$msg = $this->input->post();
		$msg['occupation'] = (empty($msg['occupation']))?'':implode(",", $msg['occupation']);
		$msg['purpose'] = (empty($msg['purpose']))?'':implode(",", $msg['purpose']);	

		if ( $isExist ){	//insert or update
			$this->Schengen_Cn_Ru_Model->update_entry($id, $msg);
		}else{
			$this->Schengen_Cn_Ru_Model->insert_entry($msg);
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Cn_Ru_Model->update_entry($id, $attach);
		
		redirect('schengen/cn_ru/'.$id.'/'.$cateid);
	}	
	
	
	/**
	 * 67.中国主表法文签证
	 */
	public function cn_fr($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Cn_Fr_Model','',TRUE);
			$info = $this->Schengen_Cn_Fr_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'-'.$idcard->birth_m.'-'.$idcard->birth_d;

			if (!empty($info->travel_document_issue_date)){
				$arr = explode("/", $info->travel_document_issue_date);
				$info->travel_document_issue_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			if (!empty($info->travel_document_valid_date)){
				$arr = explode("/", $info->travel_document_valid_date);
				$info->travel_document_valid_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			$info->avatar = $this->_getAvatar($id);
		}	
		
		//checkbox recover
		$info->occupation = explode(',', @$info->occupation);
		$info->purpose = explode(',', @$info->purpose);
		
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_cn_fr', $data);
	}
	
	/**
	 * 67.中国主表法文签证更新
	 */
	public function cn_fr_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());	
		$id = $this->input->post('id');

		$this->load->model('Schengen_Cn_Fr_Model','',TRUE);
		$info = $this->Schengen_Cn_Fr_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		//checkbox recover		
		$msg = $this->input->post();
		$msg['occupation'] = (empty($msg['occupation']))?'':implode(",", $msg['occupation']);
		$msg['purpose'] = (empty($msg['purpose']))?'':implode(",", $msg['purpose']);	

		if ( $isExist ){	//insert or update
			$this->Schengen_Cn_Fr_Model->update_entry($id, $msg);
		}else{
			$this->Schengen_Cn_Fr_Model->insert_entry($msg);
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Cn_Fr_Model->update_entry($id, $attach);
		
		redirect('schengen/cn_fr/'.$id.'/'.$cateid);
	}	
	
	
	/**
	 * 68.中国主表韩文签证
	 */
	public function cn_kr($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Cn_Kr_Model','',TRUE);
			$info = $this->Schengen_Cn_Kr_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'-'.$idcard->birth_m.'-'.$idcard->birth_d;

			if (!empty($info->travel_document_issue_date)){
				$arr = explode("/", $info->travel_document_issue_date);
				$info->travel_document_issue_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			if (!empty($info->travel_document_valid_date)){
				$arr = explode("/", $info->travel_document_valid_date);
				$info->travel_document_valid_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			$info->avatar = $this->_getAvatar($id);
		}	
		
		//checkbox recover
		$info->occupation = explode(',', @$info->occupation);
		$info->purpose = explode(',', @$info->purpose);
		
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_cn_kr', $data);
	}
	
	/**
	 * 68.中国主表韩文签证更新
	 */
	public function cn_kr_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());	
		$id = $this->input->post('id');

		$this->load->model('Schengen_Cn_Kr_Model','',TRUE);
		$info = $this->Schengen_Cn_Kr_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		//checkbox recover		
		$msg = $this->input->post();
		$msg['occupation'] = (empty($msg['occupation']))?'':implode(",", $msg['occupation']);
		$msg['purpose'] = (empty($msg['purpose']))?'':implode(",", $msg['purpose']);	

		if ( $isExist ){	//insert or update
			$this->Schengen_Cn_Kr_Model->update_entry($id, $msg);
		}else{
			$this->Schengen_Cn_Kr_Model->insert_entry($msg);
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Cn_Kr_Model->update_entry($id, $attach);
		
		redirect('schengen/cn_kr/'.$id.'/'.$cateid);
	}		
	
	/**
	 * 69.中国附表通用签证
	 */
	public function cn_exten($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Cn_Exten_Model','',TRUE);
			$info = $this->Schengen_Cn_Exten_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $info->surname.' '.$info->firstname;
			$info->birth = $idcard->birth_y.'-'.$idcard->birth_m.'-'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_cn_exten', $data);
	}
	
	/**
	 * 69.中国附表通用签证更新
	 */
	public function cn_exten_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());	
		$id = $this->input->post('id');

		$this->load->model('Schengen_Cn_Exten_Model','',TRUE);
		$info = $this->Schengen_Cn_Exten_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Cn_Exten_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Cn_Exten_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Cn_Exten_Model->update_entry($id, $attach);
		
		redirect('schengen/cn_exten/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 70.中国附表纽约签证
	 */
	public function cn_extny($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Cn_Extny_Model','',TRUE);
			$info = $this->Schengen_Cn_Extny_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $info->surname.' '.$info->firstname;
			$info->birth = $idcard->birth_y.'-'.$idcard->birth_m.'-'.$idcard->birth_d;
			$info->avatar = $this->_getAvatar($id);
		}	
		
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_cn_extny', $data);
	}
	
	/**
	 * 70.中国附表纽约签证更新
	 */
	public function cn_extny_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());	
		$id = $this->input->post('id');

		$this->load->model('Schengen_Cn_Extny_Model','',TRUE);
		$info = $this->Schengen_Cn_Extny_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Cn_Extny_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Cn_Extny_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Cn_Extny_Model->update_entry($id, $attach);
		
		redirect('schengen/cn_extny/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 71.英国学生签证
	 */
	public function uk_student($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Uk_Student_Model','',TRUE);
			$info = $this->Schengen_Uk_Student_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_uk_student', $data);
	}
	
	/**
	 * 71.英国学生签证更新
	 */
	public function uk_student_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Uk_Student_Model','',TRUE);
		$info = $this->Schengen_Uk_Student_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;
		
		//checkbox
		$data = $this->input->post();
		$data = empty($data['ck_14'])?array_merge($data, array('ck_14'=>0)):$data;

		if ( $isExist ){	//insert or update
			$this->Schengen_Uk_Student_Model->update_entry($id, $data);
		}else{
			$this->Schengen_Uk_Student_Model->insert_entry($data);
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Uk_Student_Model->update_entry($id, $attach);
		
		redirect('schengen/uk_student/'.$id.'/'.$cateid);
	}
	
	
	/**
	 * 72.英国学生签证附表
	 */
	public function uk_studentex($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Uk_Studentex_Model','',TRUE);
			$info = $this->Schengen_Uk_Studentex_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_uk_studentex', $data);
	}
	
	/**
	 * 72.英国学生签证附表更新
	 */
	public function uk_studentex_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Uk_Studentex_Model','',TRUE);
		$info = $this->Schengen_Uk_Studentex_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;
		
		//checkbox
		$data = $this->input->post();
		$data = empty($data['ck_210'])?array_merge($data, array('ck_210'=>0)):$data;
		$data = empty($data['ck_51'])?array_merge($data, array('ck_51'=>0)):$data;
		$data = empty($data['ck_54_1'])?array_merge($data, array('ck_54_1'=>0)):$data;
		$data = empty($data['ck_54_2'])?array_merge($data, array('ck_54_2'=>0)):$data;
		$data = empty($data['ck_515'])?array_merge($data, array('ck_515'=>0)):$data;
		$data = empty($data['ck_516'])?array_merge($data, array('ck_516'=>0)):$data;
		$data = empty($data['ck_517_1'])?array_merge($data, array('ck_517_1'=>0)):$data;
		$data = empty($data['ck_517_2'])?array_merge($data, array('ck_517_2'=>0)):$data;
		$data = empty($data['ck_64'])?array_merge($data, array('ck_64'=>0)):$data;
		

		if ( $isExist ){	//insert or update
			$this->Schengen_Uk_Studentex_Model->update_entry($id, $data);
		}else{
			$this->Schengen_Uk_Studentex_Model->insert_entry($data);
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Uk_Studentex_Model->update_entry($id, $attach);
		
		redirect('schengen/uk_studentex/'.$id.'/'.$cateid);
	}
	
	/**
	 * 73.澳大利亚学生申根
	 */
	public function au_student($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Au_Student_Model','',TRUE);
			$info = $this->Schengen_Au_Student_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_au_student', $data);
	}
	
	/**
	 * 73.澳大利亚学生申根更新
	 */
	public function au_student_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Au_Student_Model','',TRUE);
		$info = $this->Schengen_Au_Student_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Au_Student_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Au_Student_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Au_Student_Model->update_entry($id, $attach);
		
		redirect('schengen/au_student/'.$id.'/'.$cateid);
	}
	
	/**
	 * 74.加拿大学生签证
	 */
	public function ca_student($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ca_Student_Model','',TRUE);
			$info = $this->Schengen_Ca_Student_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			
			if (!empty($info->travel_document_issue_date)){
				$arr = explode("/", $info->travel_document_issue_date);
				$info->travel_document_issue_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			if (!empty($info->travel_document_valid_date)){
				$arr = explode("/", $info->travel_document_valid_date);
				$info->travel_document_valid_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}

			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ca_student', $data);
	}
	
	/**
	 * 74.加拿大学生签证更新
	 */
	public function ca_student_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ca_Student_Model','',TRUE);
		$info = $this->Schengen_Ca_Student_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ca_Student_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ca_Student_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ca_Student_Model->update_entry($id, $attach);
		
		redirect('schengen/ca_student/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 75.新西兰学生签证
	 */
	public function nz_student($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Nz_Student_Model','',TRUE);
			$info = $this->Schengen_Nz_Student_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;

			$info->avatar = $this->_getAvatar($id);
		}	
		
		//checkbox recover
		$info->g1 = explode(',', @$info->g1);
		$info->j4 = explode(',', @$info->j4);

		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_nz_student', $data);
	}
	
	/**
	 * 75.新西兰学生签证更新
	 */
	public function nz_student_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Nz_Student_Model','',TRUE);
		$info = $this->Schengen_Nz_Student_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		//checkbox
		$data = $this->input->post();
		$data = empty($data['is_f5'])?array_merge($data, array('is_f5'=>0)):$data;
		$data['g1'] = (empty($data['g1']))?'':implode(",", $data['g1']);
		$data['j4'] = (empty($data['j4']))?'':implode(",", $data['j4']);
		
		if ( $isExist ){	//insert or update
			$this->Schengen_Nz_Student_Model->update_entry($id, $data);
		}else{
			$this->Schengen_Nz_Student_Model->insert_entry($data);
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Nz_Student_Model->update_entry($id, $attach);
		
		redirect('schengen/nz_student/'.$id.'/'.$cateid);
	}	
	
	/**
	 * 76.日本留学调查
	 */
	public function jp_student($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Jp_Student_Model','',TRUE);
			$info = $this->Schengen_Jp_Student_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->name = $idcard->surname.' '.$idcard->firstname;
			$info->avatar = $this->_getAvatar($id);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_jp_student', $data);
	}
	
	/**
	 * 76.日本留学调查更新
	 */
	public function jp_student_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Jp_Student_Model','',TRUE);
		$info = $this->Schengen_Jp_Student_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Jp_Student_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Jp_Student_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Jp_Student_Model->update_entry($id, $attach);
		
		redirect('schengen/jp_student/'.$id.'/'.$cateid);
	}
	
	/**
	 * 77.法国学生签证
	 */
	public function fr_student($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Fr_Student_Model','',TRUE);
			$info = $this->Schengen_Fr_Student_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_y.'-'.$idcard->birth_m.'-'.$idcard->birth_d;
			
			if (!empty($info->travel_document_issue_date)){
				$arr = explode("/", $info->travel_document_issue_date);
				$info->travel_document_issue_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
			if (!empty($info->travel_document_valid_date)){
				$arr = explode("/", $info->travel_document_valid_date);
				$info->travel_document_valid_date = $arr[2].'-'.$arr[1].'-'.$arr[0];
			}
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_fr_student', $data);
	}
	
	/**
	 * 77.法国学生签证更新
	 */
	public function fr_student_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Fr_Student_Model','',TRUE);
		$info = $this->Schengen_Fr_Student_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Fr_Student_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Fr_Student_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Fr_Student_Model->update_entry($id, $attach);
		
		redirect('schengen/fr_student/'.$id.'/'.$cateid);
	}
	
	/**
	 * 78.法国学生签证附表
	 */
	public function fr_studentex($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Fr_Studentex_Model','',TRUE);
			$info = $this->Schengen_Fr_Studentex_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_fr_studentex', $data);
	}
	
	/**
	 * 78.法国学生签证附表更新
	 */
	public function fr_studentex_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Fr_Studentex_Model','',TRUE);
		$info = $this->Schengen_Fr_Studentex_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Fr_Studentex_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Fr_Studentex_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Fr_Studentex_Model->update_entry($id, $attach);
		
		redirect('schengen/fr_studentex/'.$id.'/'.$cateid);
	}
	
	/**
	 * 79.德国学生签证
	 */
	public function de_student($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_De_Student_Model','',TRUE);
			$info = $this->Schengen_De_Student_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'/'.$idcard->birth_m.'/'.$idcard->birth_y;
			
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_de_student', $data);
	}
	
	/**
	 * 79.德国学生签证更新
	 */
	public function de_student_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_De_Student_Model','',TRUE);
		$info = $this->Schengen_De_Student_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_De_Student_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_De_Student_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_De_Student_Model->update_entry($id, $attach);
		
		redirect('schengen/de_student/'.$id.'/'.$cateid);
	}
	
	/**
	 * 80.瑞士学生签证
	 */
	public function ch_student($id, $cateid){
		!(empty($id) || empty($cateid)) || show_error('參數錯誤，请查证后再试' );
		
		$info = null;
		$filled = null;
		if ( !empty($id) ){
			$this->load->model('Schengen_Ch_Student_Model','',TRUE);
			$info = $this->Schengen_Ch_Student_Model->get_one($id);
			$this->load->library('fillform',array('id'=>$id));
			$filled = $this->fillform->getFilled();
		}
		//autofill
		if( empty($info) ){
			$info = (object) $info;
			$idcard = $this->fillform->getIdCard();
			$info = $idcard;
			$info->birth = $idcard->birth_d.'-'.$idcard->birth_m.'-'.$idcard->birth_y;
			
			$info->travel_document_issue_date = str_replace('/', '-', $info->travel_document_issue_date);
			$info->travel_document_valid_date = str_replace('/', '-', $info->travel_document_valid_date);
		}	
		$data = array(
			'id' => $id,
			'cateid' => $cateid,
			'info' => $info,
			'forms' => $filled,
		);
		//print_r($data);
		$this->load->view('schengen_ch_student', $data);
	}
	
	/**
	 * 80.瑞士学生签证更新
	 */
	public function ch_student_update($cateid){
		!empty($cateid) || show_error('參數錯誤，请查证后再试' );
		
		//print_r($this->input->post());		
		$id = $this->input->post('id');

		$this->load->model('Schengen_Ch_Student_Model','',TRUE);
		$info = $this->Schengen_Ch_Student_Model->get_one($id);
		$isExist = (empty($info))?FALSE:TRUE;

		if ( $isExist ){	//insert or update
			$this->Schengen_Ch_Student_Model->update_entry($id, $this->input->post());
		}else{
			$this->Schengen_Ch_Student_Model->insert_entry($this->input->post());
			//update forms 
			$this->load->model('Archive_Idcard_Model','',TRUE);
			$this->Archive_Idcard_Model->update_forms($id, $cateid);
		}
		
		$attach = $this->_uploadProcess($id);
		if (! empty($attach) ) $this->Schengen_Ch_Student_Model->update_entry($id, $attach);
		
		redirect('schengen/ch_student/'.$id.'/'.$cateid);
	}
	
	/**
	* 处理图片和附件
	*/
	private function _uploadProcess($id){
		//print_r($_FILES);
		//== photo 处理
		$this->load->helper('directory');
		$this->load->library('upload');
		$attach = array();
		
		//获得用户头像
		$attach['avatar'] = $this->_getAvatar($id);

		if( $_FILES['userphoto']['error']==UPLOAD_ERR_OK )
		{
			$path = create_folder('images/uploads/avatar/'.floor($id/1000) );
			$config['upload_path'] = $path;
			$config['file_name'] = $id.substr($_FILES['userphoto']['name'],strrpos($_FILES['userphoto']['name'], "."));
			$config['overwrite'] = TRUE;
			$config['allowed_types'] = 'gif|jpg|png';
			$config['max_size'] = '2048';
			//$config['max_width'] = '1024';
			//$config['max_height'] = '768';

			$this->upload->initialize($config);
			if ( ! $this->upload->do_upload('userphoto'))
			{
				show_error($this->upload->display_errors());
			} 
			else
			{
				$data = $this->upload->data();
				//print_r($data);
				$avatar = $path.$data['file_name'];
				$this->load->model('User_Avatar_Model','',TRUE);
				if (empty($attach['avatar'])) 
					$this->User_Avatar_Model->insert_entry(array('id'=>$id,'avatar'=>$avatar));
				else
					$this->User_Avatar_Model->update_entry($id, array('avatar'=>$avatar));
				$attach['avatar'] = $avatar;
			}
		}
		if ( $_FILES['userfile']['error']==UPLOAD_ERR_OK  )
		{
			unset($config);
			$path = create_folder('images/uploads/attachment/'.date('Y').'/'.date('m') );
			$config['upload_path'] = $path;
			$config['allowed_types'] = 'pdf|zip|rar|doc';
			$config['max_size'] = '10240';
			$config['encrypt_name'] = TRUE;
			
			$this->upload->initialize($config);
			if ( ! $this->upload->do_upload('userfile'))
			{
				show_error($this->upload->display_errors());
			} 
			else
			{
				$data = $this->upload->data();
				//print_r($data);
				$attach['attachment'] = $path.$data['file_name'];
			}
		}
		return $attach;
	}
	
	/**
	* 获得头像
	*/
	private function _getAvatar($userId){
		$this->load->model('User_Avatar_Model','',TRUE);
		$info = $this->User_Avatar_Model->get_one($userId);
		if (empty($info)) return "";
		return $info->avatar;
	}
}


/* End of file schengen.php */
/* Location: ./application/controllers/schengen.php */